<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://unpkg.com/vue@next"></script>
    <div id="app">
        <!-- 绑不绑定v-on:update:foo都不影响bar值双向绑定 -->
        <todo-item 
            v-model:foo="bar" 
        >
        </todo-item>
    </div>
    <script>
        const vueOpt = {
            data(){
                return {
                    bar: 'kenny.bai'
                }
            },

            methods: {
                inputEvent(e){
                    console.log('e:', e, 'bar:', this.bar);
                }
            },

            mounted(){
                setInterval(()=>{
                    console.log('bar:', this.bar);
                }, 1000);
            }
        }

        const app = Vue.createApp(vueOpt);

        app.component('todo-item', {
            data(){
                return {

                }
            },
            props:['foo'],
            // 必须触发update:foo事件
            template: 
            `
                <input type="text" :value="foo" @input="$emit('update:foo', $event.target.value)">
            `
        })

        app.mount('#app');
    </script>

</body>
</html>